<!--  -->
<template>
  <div class="helloworld" style="width: 100%; height: 100%">
    <div
      id="main"
      style="width: 80%; height: 60%; background-color: skyblue"
    ></div>
    <hr>
    <h2>{{$store.state.a.userInfo}}</h2>
    <button @click="btnClick">点击获取姓名</button>
    <hr>
    <h2>{{$store.state.a.count}}</h2>
    <button @click="add">点击加1</button>
  </div>
</template>

<script>
// import * as echarts from 'echarts'
export default {
  name: 'HelloWorld',
  components: {
  },
  mounted () {
    var myChart = this.$echarts.init(document.getElementById('main'))
    var option = {
      title: {
        text: 'ECharts 入门示例'
      },
      tooltip: {},
      legend: {
        data: ['销量']
      },
      xAxis: {
        data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
      },
      yAxis: {},
      series: [
        {
          name: '销量',
          type: 'bar',
          data: [5, 20, 36, 10, 10, 20]
        }
      ]
    }
    myChart.setOption(option)
    window.addEventListener('resize', function () {
      myChart.resize()
    })
  },
  data () {
    return {
    }
  },
  methods: {
    btnClick () {
      // this.$store.getters
      alert(this.$store.getters.getUserName)
    },
    add () {
      this.$store.commit('updateUsername', {
        name: 'zjp'
      })
    }
  }
}
</script>

<style lang = 'scss'  scoped>
  #app, .home{
    width: 100%;
    height: 100%
  }
</style>
